//
//  GKZYUserResetPasswordView.m
//  GKZYAid
//
//  Created by lanou3g on 16/3/14.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYUserResetPasswordView.h"

#define LTVIEW_X self.frame.size.width * 0.15
#define LTVIEW_WIDTH self.frame.size.width * 0.7
#define LTVIEW_HEIGHT self.frame.size.height * 0.05
#define GAP self.frame.size.height * 0.03
#define NUM 101

@implementation GKZYUserResetPasswordView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self addAllViews];
    }
    return self;
}

- (void)addAllViews
{
    self.backgroundColor = [UIColor whiteColor];
    
    self.userName = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X ,self.frame.size.height * 0.1 + 44, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userName setLabelText:@"用户名:" textFieldPlaceholder:@"请输入用户名" isCiphertext:NO textFieldTag:(self.userName.frame.origin.y + NUM)];
    [self addSubview:self.userName];
    
    self.userPrimaryPassword = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userName.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userPrimaryPassword setLabelText:@"密码:" textFieldPlaceholder:@"请输入原密码" isCiphertext:YES textFieldTag:(self.userPrimaryPassword.frame.origin.y + NUM)];
    [self addSubview:self.userPrimaryPassword];
    
    self.userNewPassword  = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userPrimaryPassword.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userNewPassword setLabelText:@"新密码:" textFieldPlaceholder:@"请输入新密码" isCiphertext:YES textFieldTag:(self.userPrimaryPassword.frame.origin.y + NUM)];
    [self addSubview:self.userNewPassword];
    
    self.userNewPasswordSure = [[LabelTextFieldView alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userNewPassword.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT)];
    [self.userNewPasswordSure setLabelText:@"密码确认:" textFieldPlaceholder:@"请再次输入新密码" isCiphertext:YES textFieldTag:(self.userNewPasswordSure.frame.origin.y + NUM)];
    [self addSubview:self.userNewPasswordSure];
    
    self.buttonSure = [UIButton buttonWithType:UIButtonTypeCustom];
    self.buttonSure.frame = CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userNewPasswordSure.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT * 1.5);
    [self.buttonSure setTitle:@"修改" forState:UIControlStateNormal];
    self.buttonSure.backgroundColor = [UIColor orangeColor];
    [self addSubview:self.buttonSure];
    
    self.labelHint = [[UILabel alloc] initWithFrame:CGRectMake(LTVIEW_X, CGRectGetMaxY(self.buttonSure.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT * 2)];
    self.labelHint.text = @"*注:请将do-not-reply@apps.leancloud.cn\n添加到邮箱白名单中";
    self.labelHint.textColor = [UIColor redColor];
    self.labelHint.textAlignment = NSTextAlignmentCenter;
    self.labelHint.font = [UIFont systemFontOfSize:15.0];
    self.labelHint.numberOfLines = 0;
    [self addSubview:self.labelHint];
}

- (void)layoutSubviews
{
    self.userName.frame = CGRectMake(LTVIEW_X ,self.frame.size.height * 0.1 + 44, LTVIEW_WIDTH, LTVIEW_HEIGHT);
    
    self.userPrimaryPassword.frame = CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userName.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT);
    
    self.userNewPassword.frame  = CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userPrimaryPassword.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT);
    
    self.userNewPasswordSure.frame = CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userNewPassword.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT);
    
    self.buttonSure.frame = CGRectMake(LTVIEW_X, CGRectGetMaxY(self.userNewPasswordSure.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT * 1.5);
    
    self.labelHint.frame = CGRectMake(LTVIEW_X, CGRectGetMaxY(self.buttonSure.frame) + GAP, LTVIEW_WIDTH, LTVIEW_HEIGHT * 2);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
